import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/login/login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/login/getInfo',
    method: 'get',
    params: { token }
  })
}

export function getUserByAccount(account) {
  return request({
    url: '/user/getUserByAccount',
    method: 'get',
    params: { account }
  })
}

export function getTotalAchievement(params) {
  return request({
    url: '/user/getTotalAchievement',
    method: 'get',
    params
  })
}

export function getTotalProject(params) {
  return request({
    url: '/user/getTotalProject',
    method: 'get',
    params
  })
}
// 新增的用户管理接口
export function getUserList(params) {
  return request({
    url: '/user/list',
    method: 'get',
    params
  })
}

export function addUser(data) {
  return request({
    url: '/user/add',
    method: 'post',
    data
  })
}

export function updateUser(data) {
  return request({
    url: '/user/update',
    method: 'put',
    data
  })
}

export function deleteUser(id) {
  return request({
    url: `/user/delete/${id}`,
    method: 'delete'
  })
}

export function getDeptList() {
  return request({
    url: '/department/list',
    method: 'get'
  })
}

export function changePassword(data) {
  return request({
    url: '/user/updatePassword',
    method: 'post',
    data
  })
}

export function ssoUserInfo() {
  return request({
    url: '/sso/user-info',
    method: 'get'
  })
}

export function logout() {
  return request({
    url: '/sso/logout',
    method: 'get'
  })
}
